import { makeRequiredRule } from '../../../utils/index'

const label = '参赛单位'
const name = 'entry'
let i = 1
const uniqueId = () => `${name}${i++}`

export default {
  label,
  name,
  rule() {
    return {
      type: 'select',
      field: uniqueId(),
      title: label,
      effect: {
        fetch: {
          action: 'https://match.zh24.shop/manager/register/list',
          to: 'options',
          method: 'POST',
          headers: {
            Authorization:
              'Bearer Bearer 79|v3NM3nUCX8P2pGKtqTawNsmqDLD9lqu9NtyJzDEH'
          },
          parse(res) {
            return res.data.data.map(row => {
              return {
                label: row.name,
                value: row.id
              }
            })
          }
        }
      },
      props: {
        clearable: true,
        filterable: true,
        defaultFirstOption: true
      }
    }
  },
  props() {
    return [makeRequiredRule()]
  }
}
